﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CodeGenerator
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string msg = "";
            string content = txtContent.Text;
            var m = new csharp.winformCode(content);
            if (!m.statusOk)
            {
                lblMessage.Text = m.errorMessage;
                return;
            }

            //foreach (var s in m.txts)
            //{
            //    sb.Append("[" + s + "],");
            //}
            //msg = m.createMsSql();
            msg = m.getCsStr();
            var f = new frmOutPut();
            f.txtContent2.Text = msg;
            f.txtContent.Text = m.getCsDesignerStr();
            f.txtContent3.Text = m.getListCsStr();
            f.Show();
            //lblMessage.Text = msg;
            return;

            //string projectType = "web";
            //if (rdCodeTyeWeb.Checked) projectType = "web";
            //if (rdCodeTypeWinform.Checked) projectType = "winform";

            //if (rdCSharp.Checked) generateCodeForCSharp(projectType);
            //if (rdPhp.Checked) generateCodeForPhp(projectType);
            //if (rdAsp.Checked) generateCodeForAsp(projectType);

        }

        /// <summary>
        /// 生成C#代码
        /// </summary>
        /// <param name="projectType"></param>
        private void generateCodeForCSharp(string projectType)
        {
            switch (projectType)
            {
                case "web": csharp.webCode.genCode(); break;
                default: ; break;
            }

        }

        /// <summary>
        /// 生成asp代码
        /// </summary>
        /// <param name="projectType"></param>
        private void generateCodeForAsp(string projectType)
        {

        }

        /// <summary>
        /// 生成php代码
        /// </summary>
        /// <param name="projectType"></param>
        private void generateCodeForPhp(string projectType)
        {

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

    }
}
